Set up the IMU

My connection:

            A red circuit board with wires

Description automatically generated

·        Connect IMU, Artemis, and PC together, try the IMU example codes:

A screenshot of a computer

Description automatically generated 

·        AD0_VAL is the last bit of I2C address of IMU, set it to 0 since we haven’t soldered 2 IMU pads and enabled the ADR jumper yet.

·        Accelerometer measures the acceleration of IMU board, the gyroscope measures the angular acceleration of the board. In motions such as rotate or flip the IMU, both acceleration and gyroscope readings change; when accelerate it, only the accelerometer;s reading changes; In angular motions, accelerometer’s reading are changed according to current IMU orientation, but gyroscope’s reading only changes when there’s movements, i.e. when IMU is stationary with an angle to the desk, the former’s reading don’t necessarily be 0, but the later’s is around 0.

 

 

Accelerometer

Roll&Pitch with angles at {-90, 0, 90} degrees

·        When roll is 90 degrees, the reading from accelerometer is 87~88, error is less than 3%, is acceptable, thus the accelerometer can be considered as accurate:

o   A graph with purple lines

Description automatically generated

 

·        When pitch is -90 degrees, the reading from accelerometer is -87~-89, the error is less than 3%, the accelerometer can be considered as accurate:

o   A green line graph on a white background

Description automatically generated

 

·        The equation used to calculate these are 180 / M_PI * atan2(sensor->accY() and 180 / M_PI * atan2(sensor->accX(), sensor->accZ()), 2, 0), sensor->accZ()), 2, 0), which is essentially the 2 equations mentioned in lecture:

o   A black background with white text

Description automatically generated

·        From the graph above, the accuracy of the accelerometer can be shown. It has some error, but within the acceptence range.

Analysis of accelerometer’s noise

·        When pounding the table, the Fourier graph looks like:

o   A graph of a number of objects

Description automatically generated with medium confidence

o   It is easy to tell there’s high frequency noise.

o   Using the formula from lecture,

A black screen with white text

Description automatically generated

I implemented a Low pass filter:

A computer screen shot of a code

Description automatically generated

 

o   With this low pass filter, the high frequency errors are reduced a lot:

§  A graph of a number of blue and orange lines

Description automatically generated

·        Simulate the noise by tapping the table, then draw the Fourier graph, and we can see there’ s no significant high frequency noise. This might be because of the IMUS’s internal low pass filter.  

Gyroscope

·        The degree measurement by gyroscope is implemented using the formula from lecture notes:

o  

o   Substitute the values into the equation, I got the following code:

              roll_gy += 0.006935 * sensor->gyrX();

       pitch_gy += 0.006935 * sensor->gyrY();

       yaw_gy += 0.006935 * sensor->gyrZ();

where the number 0.006935 is the time between each measurement, the dt.

·        Graph of roll’s and pitch’s readings

o   Roll:

o   A graph on a white background

Description automatically generated

o   Pitch:

o   A graph on a white background

Description automatically generated

·        Comparison between the diagram of gyroscope and accelerometer:

o   A close-up of a computer screen

Description automatically generated

o   The sketch of gyroscope is much smoother than that of accelerometer, but it has a continuous drifting.

·        The design of complimentary filter and choice of parameter

o  

o   I used the equation above. The value of alpha I chose was 0.5, which makes the final curve smoothy without having too much drifting:

§  Roll

§  A graph with a line drawn on it

Description automatically generated

§  Pitch   

§  A green line graph on a white background

Description automatically generated

§   

 

Data collection

·        When I was dealing with data collection, I had trouble with sending all data to computer using Bluetooth, but fortunately I got solution in the end: improve the size of the data by using simplest notations for parsing only, and split it, then store the data needed into an array(see the code graph below):

o   A white background with black numbers

Description automatically generated

·        In the picture above, among every 3 numbers splited by ‘|’, the 1st is millitime, 2nd is row, the 3rd is pitch. The sampling time interval is 0.006935, which is got by measuring the average interval.

o   A screenshot of a computer code

Description automatically generated

 

·        By adding enough sampling data point in the ble_arduino, I got a 7 seconds IMU data with time stamp:

o   A screenshot of a computer

Description automatically generated